<template>
	<view>
		<uni-search-bar placeholder="找房子" @confirm="shou" @cancel="getlun()" @clear="getlun()"></uni-search-bar>
		<uni-group title="功能分类">
			<view class="item-container">
				<view class="thumb-box" v-for="(item1, index1) in list2" :key="index1" @click="toinde(item1)">
					<image class="item-menu-image" src="../../../../static/icons/baoyu.png" mode=""></image>
					<view class="item-menu-name">{{item1}}</view>
				</view>
			</view>
		</uni-group>
		<uni-group title="房源列表">
			<uni-card @click="toyuan(item.id)" v-for="(item,index) in list" :thumbnail="base+item.pic" :title="item.sourceName">
				<view>房源面积：{{item.areaSize}}平方米</view>
				<view>价格：{{item.price}}</view>
				<view>房源简介：{{item.description}}</view>
				<view></view>
			</uni-card>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				list:[],
				list2:['二手','租房','楼盘','中介'],
			}
		},
		onLoad() {
			this.getlun()
		},
		methods: {
			toyuan(id){
				uni.navigateTo({
					url:'xiangq?id='+id
				})
			},
			shou(e){
				this.list = this.list.filter((item)=>{
					if(item.sourceName.indexOf(e.value)>= 0){
						return item
					}
				})
			},
			
			toinde(name){
				this.$get(this.base + '/prod-api/api/house/housing/list',{
					houseType:name
				}).then((res) => {
					this.list = res.rows
				})
			},
			getlun() {
				this.$get(this.base + '/prod-api/api/house/housing/list').then((res) => {
					this.list = res.rows
				})
			}
		}
	}
</script>

<style>
	.item-container {
		display: flex;
		flex-wrap: wrap;
	}

	.thumb-box {
		width: 25%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		margin-top: 20rpx;
	}

	.item-menu-image {
		width: 120rpx;
		height: 120rpx;
	}
</style>
